<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=false;"
          name="viewport">
    <title>祝福留言</title>
    <meta http-equiv="keywords" content="{$arr.bridegroom}/{$arr.bride}"/>
    <meta name="description" content="{$arr.bridegroom}/{$arr.bride}的朋友看了都说赞！"/>
    <link rel="stylesheet" type="text/css" href="__CSS__/leave.css"/>
    <script type="text/javascript" src="__JS__/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="__JS__/jquery.reveal.js"></script>
    <script type="text/javascript" src="__JS__/lhgdialog.js"></script>
    <!-- 
    <script type="text/javascript" src="__JS__/reply.js"></script>
     -->
</head>
<body>

<input id="muid" type="hidden" value="27093"/>

<div class="leave">
    <h3 class="leave_h3">祝福寄语</h3>

    <div class="name_text">
        <label class="name_label">姓名：</label>
        <input id="user_name" type="text"/>
    </div>
    <div style="clear:both;"></div>
    <div class="name_text">
        <label class="name_label">出席：</label>
        <select id="reply_num" name="reply_num">
            <option value="-1" selected>出席</option>
            <option value="0">无法出席</option>
            <option value="1">1人出席</option>
            <option value="2">2人出席</option>
            <option value="3">多人出席</option>
        </select>
    </div>
    <div style="clear:both;"></div>
    <div class="leave_text" style="margin-top:10px;">
        <label class="name_label">寄语：</label>
        <script id="container" name="content" type="text/plain">我要祝福...</script>
        <script type="text/javascript" src="__JSPLUGINS__/ueditor/ueditor.config.js"></script>
        <script type="text/javascript" src="__JSPLUGINS__/ueditor/ueditor.all.js"></script>
        <script type="text/javascript">var ue = UE.getEditor('container');</script>

        <div class="leave_bottom">

            <a href="javascript:void(0);" class="ds-post-button" onclick="subMsgForm()">发布</a>
        </div>
    </div>

    <p class="Blessing">祝福留言</p>

    <div id="msg_area">
        <include file="default/Index/ajax/page"/>
    </div>


</div>

</body>
</html>
<script type="text/javascript">
    function subMsgForm() {
	    var user_name = $('#user_name').val();
	    var reply_num = $('#reply_num').val();
	    var content = ue.getContent();
	    console.log(user_name);
	    console.log(reply_num);
	    console.log(content);
	    // 姓名验证
	    if (user_name == '' || user_name == '您的姓名') {
	        jQuery.dialog.tips('<p class="tips_12_g">请填写您的姓名</p>');
	        jQuery('#user_name').focus();
	        return;
	    }
	    if(reply_num<0){
	        jQuery.dialog.tips('<p class="tips_12_g">请选择出席认识</p>');
	        return;
	    }
	    // 留言验证
	    if (content.length < 5) {
	        jQuery.dialog.tips('<p class="tips_12_g">留言内容不能少于5个字符</p>');
	        return;
	    }
        var data = {'user_name': user_name, 'content': content, 'reply_num': reply_num};

        $.ajax({
            'type': 'post',
            'url': '{:U('addPresence')}',
            'data': data,
            'dataType': 'json', //json Obj
            success: function (result) {
                if (result.error == 200) {
                    location.reload();
                } else {
                    jQuery.dialog.tips('<p class="tips_12_g">' + result.msg + '</p>');
                }
            }
        });
    }
    /**
     * [get_wall 分页]
     * @param  {[type]} p [页码]
     * @return {[type]}   [null]
     */
    function get_wall(p) {
        if (p > 0) {
            var data = {};
            data['pageCurrent'] = p;
            $.ajax({
                type: 'post',
                url: '{:U('presence')}',
                data: data,
                dataType: 'json',
                success: function (result) {
                    if (result) {
                        $('#msg_area').html(result);
                    } else {
                        jQuery.dialog.tips('<p class="tips_12_g"> 您当前的页码不存在!</p>');
                    }

                }
            });
        }
    }
</script>